<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>渠道管理</title>
		<link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
	    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
	    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.global.settings.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
	    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
	</head>
	<body>
		<div class="easyui-container-fluid">
			<div class="easyui-panel" style="border: none;">
              <div id="nav" class="nav">
                
              </div>
              <div class="easyui-panel" style="width:100%;border:none;">
                   <form id="ff">
                      <div style="margin-bottom:20px;">
                      	<label class="item-label">代码：</label>
                        <input class="easyui-textbox" type="text" name="code" style="width:100px;"/>
                        <label class="item-label">名称：</label>
                        <input class="easyui-textbox" type="text" name="name" style="width:100px;"/>
                        <label class="item-label">周上报：</label>
                        <select class="easyui-combobox" name="reportWeekData" data-options="panelHeight:'auto'" style="width:100px;">
                          <option value="">-请选择-</option>
                          <option value="true">是</option>
                          <option value="false">否</option>
                        </select>                     
                        <label class="item-label">月上报：</label>
                        <select class="easyui-combobox" name="reportMonthData" data-options="panelHeight:'auto'" style="width:100px;">
                          <option value="">-请选择-</option>
                          <option value="true">是</option>
                          <option value="false">否</option>
                        </select>
                          <label class="item-label">线上渠道：</label>
                          <select class="easyui-combobox" name="onlineChannel" data-options="panelHeight:'auto'" style="width:100px;">
                              <option value="">-请选择-</option>
                              <option value="true">是</option>
                              <option value="false">否</option>
                          </select>
                          <label class="item-label">退货处理：</label>
                          <select class="easyui-combobox" name="handleRejectSales" data-options="panelHeight:'auto'" style="width:100px;">
                              <option value="">-请选择-</option>
                              <option value="true">是</option>
                              <option value="false">否</option>
                          </select>
                      </div>
                      <div style="margin-bottom:20px;">

                        <label class="item-label">周报处理人：</label>
                        <select id="weekDataOption" class="easyui-combobox" name="weekDataHandleUserId" data-options="panelHeight:'150'" style="width:100px;">
                        </select>
                        <label class="item-label">月报处理人：</label>
                        <select id="monthDataOption" class="easyui-combobox" name="monthDataHandleUserId" data-options="panelHeight:'150'" style="width:100px;">
                        </select>
                        <label class="item-label">数据联系人：</label>
                        <input class="easyui-textbox" type="text" name="dataGatherer" style="width:100px;"/>
                      <label class="item-label">状态：</label>
                      <input id="entityStatus" class="easyui-switchbutton" checked style="width:80px;height:30px;" onText="是" offText="否"  >
                      <a href="javascript:void(0);" class="easyui-linkbutton c8" style="margin-left:40px;width:80px;" onclick="searchChannel()">查询</a>
                      </div>
                    </form>
                 </div>
                 <div class="table-wrapper">
                   <table id="datagrid" data-options="fitColumns:true,scrollbarSize:0">
                     <thead>
                       <tr>
                         <th data-options="field:'code',align:'center'" width="60">代码</th>
                         <th data-options="field:'name',align:'center'" width="80">名称</th>
                         <th data-options="field:'remark',align:'center'" width="100">备注</th>
                         <th data-options="field:'reportWeekData',align:'center',formatter:boolFormatter" width="70">周上报</th>
                         <th data-options="field:'reportMonthData',align:'center',formatter:boolFormatter" width="70">月上报</th>
                         <th data-options="field:'onlineChannel',align:'center',formatter:boolFormatter" width="70">线上渠道</th>
                         <th data-options="field:'handleRejectSales',align:'center',formatter:boolFormatter" width="70">退货</th>
                         <th data-options="field:'mergeWeekFlag',align:'center',formatter:boolFormatter" width="70">合并周</th>
                         <th data-options="field:'weekDataHandleUserName',align:'center'" width="70">周报处理人</th>
                         <th data-options="field:'monthDataHandleUserName',align:'center'" width="70">月报处理人</th>
                         <th data-options="field:'dataGatherer',align:'center'" width="80">数据联系人</th>
                         <th data-options="field:'recordReportFormat',align:'center',formatter:recordReportFormat" width="80">数据上报格式</th>
                         <th data-options="field:'entityStatus',align:'center',formatter:statusFormatter" width="40">状态</th>
                         <th data-options="field:'createDate',align:'center'" width="100">添加时间</th>
                         <th data-options="field:'updateTime',align:'center'" width="160">修改时间</th>
                         <th data-options="field:'action',align:'center',formatter:actions" width="160">操作</th>
                       </tr>
                     </thead>
                     <tbody>
                     </tbody>
                   </table>
                 </div>
            </div> 
         </div>
	</body>
  <script type="text/javascript">
     $(function(){
         aRecords("渠道管理","/webapp/pages/channel/channel")
           var height = $(window).height();
           var nav_height = $("#nav")._outerHeight();
           var ff_height = $("#ff").height();
           var table_height = height-nav_height-ff_height-40;
           $("#datagrid").css("max-height",table_height);
           $("#datagrid").datagrid({
               toolbar:[{
                    text:'添加渠道',
                    //iconCls:'icon-add',
                    handler:function(){
                      window.parent.addTab("添加渠道","/webapp/pages/channel/channel/add.html");
                    }
                }]
           });
           $.ajax({
               url:config.url+"/user/getAll",
               type:'get',
               xhrFields:{withCredentials:true},
               success:function (data) {
                   if(data){
                       data.unshift({id:"",username:"-请选择-"});
                       $("#weekDataOption,#monthDataOption").combobox({
                           data:data,
                           valueField:"id",
                           textField:"username"
                       });
                   }
               } 
           });
     });
     var reportFormatObj = {
     	"SINGLE":"单条上报", 
     	"MULTI":"多条上报"
     }
     function recordReportFormat(val, row){
     	return !!reportFormatObj[val]?reportFormatObj[val]:"单条上报";
     }

     function searchChannel() {
         var queryParams = $("#datagrid").datagrid("options").queryParams;
         var formData = getFormData(document.getElementById("ff"));
         var params = formData;//transfer(formData);
         for(var i in params){
             queryParams[i] = params[i];
             if(!queryParams[i]){
                 delete queryParams[i];
             }
         }
         queryParams["entityStatus"] = $("#entityStatus").switchbutton("options").checked==true?"OK":"DISABLE";
         $("#datagrid").datagrid("reload");
     }
  </script>
  <script type="text/javascript" src="/webapp/js/common/pagelist.js"></script>
  <script type="text/javascript">
      function edit(id){
          window.parent.addTab("修改渠道","/webapp/pages/channel/channel/add.html?id="+id);
      }
  </script>
</html>